<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html><html lang="en">
	<head>
		<!--加载header文件-->
		<?php
		include_once 'public/views/header.php';
		?>
		<link rel="stylesheet" href="public/css/list.css" />
		<link rel="stylesheet" href="public/xr/xrDatatable.css" />
		<script src="public/xr/xrDatatable.js?v=20231124"></script>
		<script src="public/js/list.js"></script>
	</head>
	<body>
		<div class="page-container container">
			<div class="searchForm">
			    <div class="searchForm-title"><i class="icon-table searchForm-title-icon"></i>数据表格<i class="icon-double-angle-up searchFormTitleIcon"></i></div>
			    <div class="searchForm-main">
					<form id="searchForm">
							<input type="text" name='param' id="param" placeholder="标题"/>
					</form>
				</div>
			</div>
			<div class="operationRow">
				<button class="pageItemButton" onclick="showDialogModal('<?=base_url()?>Admin/IndexLarge/classes_number_edit/0');"><i class="icon-edit"></i>添加</button>
			</div>
			<div class="listcontent">
				<div class='xrTableRow'>
					<table id="table" class="xrTable">
						<thead>
							<tr>
								<th name="_xrno"></th>
								<th name="_oper" style="width: 120px;">操作</th>
								<th name="_title" > 标题 </th>
								<th name="_number" > 次数 </th>
								<th name="_created_char" > 创建时间 </th>
								<th name="_updated_char" > 修改时间 </th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</body>
	<script>
		$("body").keydown(function() {
             if (event.keyCode == "13") {//keyCode=13是回车键
                 $('.searchButton').click();
             }
         });

$(function() {
		//初始化datatable
		$("#table").XRDataTable({
			ajaxUrl: "Admin/IndexLarge/classes_number_getDatas",
			paramFunc: paramFunc,
			operation: {
				"edit": ["Admin/IndexLarge/classes_number_edit/#id"],
				"icon-trash": [deleteFunc,'删除'],
			},
			hasCheckbox: false,
			afterFunc:afterFunc
		});

	// exportEvent();
});

var paramFunc = function() {
	var data = getFormJson();
	return data;
};

var afterFunc = function(){

    $("#table tbody tr").each(function() {
        var data = $("#table").getOpts().datas[$(this).index()];
        if(data.admin_type==1){
        	$(this).children("td:nth-child(2)").find(".icon-lock").hide();
        }
    });
}



var deleteFunc = function(idx, trData) {
	var msg = "是否确认删除【" + trData.title + "】?";
	swal({
		title: "请确认",
		text: msg,
		type: "warning",
		showCancelButton: true,
		closeOnConfirm: true,
		confirmButtonText: "确定",
		cancelButtonText: '取消',
		confirmButtonColor: "#ec6c62"
	}, function(isConfirm) {
		if(isConfirm) {
			$.ajax({
				type: "post",
				url: "Admin/IndexLarge/classes_number_delete/"+trData.id,
				async: true,
				success: function(data) {
					var ret = $.parseJSON(data);
					if(ret.status) {
						window.parent.topMessagePrompt('success',ret.msg);
	                    window.parent.refreshTable();
					} else {
						window.parent.topMessagePrompt('error',ret.msg);
					}
				}
			});
		}
	});
};

//导出数据
exportEvent = function() {
	$("input").keypress(function(event) {
		if(event.keyCode == "13") {
			$("#table").search();
		}
	})
	$("#export").click(function() {
		var ret = $("#table").getTableThInfo();
		ret.params = usefulArray(paramFunc());
		ret.title = "会员列表";
		locationPost("User/commonExport", {
			'json': JSON.stringify(ret)
		});
	});
};

	</script>
</html>